package com.koron.css2.clientCenter.impl;

import com.koron.css2.ServerInterface;
import com.koron.css2.clientCenter.bean.ChargeLackDetailBean;
import com.koron.css2.clientCenter.mapper.BillDetailMapper;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.serviceManage.utils.JsonUtils;
import com.koron.util.Constant;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

import java.util.List;
import java.util.Map;

/**
 * 获取用户欠费明细
 * @author 甄玉晴
 *
 */
public class ChargeLackDetail implements ServerInterface {

	@Override
	public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
		@SuppressWarnings("rawtypes")
		MessageBean<List> info = MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "查询成功", List.class);
		try {
			@SuppressWarnings("unchecked")
			Map<String,String> map = JsonUtils.objectToPojo(req.getData(), Map.class);
			String userNo=map.get("userNo");
			BillDetailMapper mapper = factory.getMapper(BillDetailMapper.class);
			
			List<ChargeLackDetailBean> list = mapper.chargeLackDetailList(userNo);
			info.setData(list);
			return info;
		} catch (Exception e) {
			logger.error("用户欠费明细查询失败" + e.getMessage(), e);
			return MessageBean.create(Constant.MESSAGE_INT_FAIL, "查询失败", null);
		}
	}

}
